<template>
	<view class="user-wallet-qh-page">
		<view class="header-box">
			<image src="../../static/images/bg_1.png" mode="widthFix" class="bg-img"></image>
			<view class="text1">趣换币收益</view>
			<view class="text2">{{myWallet.qu_money}}</view>
			<view class="text3">
				<u-icon name="volume" size="28" color="#fff"></u-icon>
				<text class="text">每日凌晨会自动兑换成余额至余额账户</text>
			</view>
		</view>
		<view class="main-box">
			<!-- <view class="tab-box">
				<view v-for="v in tabList" :key="v.id" class="tab" :class="{'is-active':v.id==currTab.id}"
					@tap="changeTab(v)">{{v.name}}</view>
			</view> -->

			<view class="list-box">
				<view class="item" v-for="item in dataList" :key="item.id">
					<view class="top-bar">
						<view class="label">{{item.type_text}}</view>
						<view class="value">{{item.status_text+item.qb}}</view>
					</view>
					<view class="content" v-if="item.type==3">
						<image :src="item.data.avatar" mode="aspectFill" class="avatar"></image>
						<view class="text">{{item.data.nickname}} {{item.data.create_time}}注册</view>
					</view>
					<view class="date row-between">
						<view>{{item.remark}}</view>
						<view>{{item.utime}}</view>
					</view>
				</view>
				<loading-footer :status="status"></loading-footer>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getQuHuanGoldList,
		getWallet
	} from '../../../api/user';
	import {
		loadingFun
	} from '../../../utils/tools';
	import {
		loadingType
	} from '../../../utils/type';
	const tabList = [{
			id: 1,
			name: '趣币记录'
		},
		// {
		// 	id: 1,
		// 	name: '兑换记录'
		// },
	];
	export default {
		data() {
			return {
				page: 1,
				status: loadingType.LOADING,
				dataList: [],
				tabList: tabList,
				currTab: tabList[0],
				myWallet: null,
			};
		},

		components: {},
		props: {},

		onLoad: function(options) {
			this.getDataList();

			// 获取钱包信息
			getWallet().then(res => {
				if (res.code != 1) return this.$toast({
					title: res.msg
				});
				this.myWallet = res.data;
			})
		},


		methods: {
			clear() {
				this.page = 1;
				this.status = loadingType.LOADING;
				this.dataList = []
			},
			changeTab(v) {
				this.currTab = v;
				this.clear();
				this.getDataList();
			},
			async getDataList() {
				const data = await loadingFun(getQuHuanGoldList, this.page, this.dataList, this.status, {
					type: this.currTab.id
				});
				if (data) {
					this.page = data.page;
					this.dataList = data.dataList;
					this.status = data.status;
				}
			}
		}
	};
</script>
<style lang="scss" scoped>
	@import "index.scss";
</style>